feat(ToastProvider): migrate to 'sonner' for stacked, animated toasts#1032
Merged
Conversation
📝 WalkthroughWalkthroughReplaced the Radix toast dependency with sonner, and updated ToastProvider to use sonner’s toast API and Toaster component instead of Radix-based local toast state and rendering. ChangesToast library migration
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant Consumer
participant ToastProvider
participant SonnerToast
participant Toaster
Consumer->>ToastProvider: notify(content, options)
ToastProvider->>SonnerToast: toast(content, { duration })
SonnerToast-->>ToastProvider: toast id
ToastProvider-->>Consumer: id.toString()
SonnerToast->>Toaster: render toast
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
tanstack-com | dc23828 | Commit Preview URL Branch Preview URL |
Jul 04 2026, 07:34 PM |
LadyBluenotes
approved these changes
Jul 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces
@radix-ui/react-toastwithsonneras the toast backend inToastProvider. The publicuseToast().notify()API is unchanged, so no consumer files were touched.Motivation
The previous setup used Radix
Toastonly as a thin shell — the queue andnotify()API were hand-rolled, and onlyToast.Root/Toast.Viewportwere borrowed. Moving tosonner(a dedicated toast library) delegates that work to a more mature implementation and improves the user-facing behavior:Toast.Viewportlaid toasts out in aflex-colwith no cap, so firing several in a row filled the right side of the screen and covered page content (e.g. the partners column).sonnershows at most a few and collapses the rest into a stack (expanding on hover), so the screen is no longer buried.w-96(384px) width on small screens, so on a 375px viewport toasts overflowed and the text was clipped, and multiple toasts stacked down the whole screen.sonnerapplies a mobile layout below 600px (full-width minus offsets), so toasts fit the viewport and no longer overflow.data-[state]animation classes, so toasts appeared and disappeared abruptly.sonneranimates them.sonnerrenders anaria-live="polite"region labeledNotificationswith anAlt+Tfocus hotkey out of the box.Preserved (unchanged)
Kept identical to the previous implementation so this is a drop-in swap:
useToast().notify(content, options?)signature — same(React.ReactNode, { durationMs? }) => string, so all 19 consumer files are untouched.options?.durationMs ?? 2500(2500ms), same as before; consumers passing a customdurationMsstill work.rounded-md border ... dark:bg-gray-800 ...) and content (flex items-start gap-2), applied viasonner'sunstyled+classNames.fixed bottom-4 right-4viewport.swipeDirections={['right']}, matching the old RadixswipeDirection="right"(sonner would otherwise also allow down-swipe at thebottom-rightposition).useTheme().resolvedTheme.Changes
package.json: remove@radix-ui/react-toast, addsonnersrc/components/ToastProvider.tsx:Toast.Provider/Toast.Root/Toast.Viewportrender tree with a single<Toaster />.toastsstate,ToastItemtype,removeToast);sonnermanages the queue internally.notify()now callssonner'stoast()while keeping the same signature and default2500msduration.position="bottom-right",offset={16},gap={8}, andswipeDirections={['right']}to match the previous viewport placement and swipe behavior.AS-IS
Light (Several clicked)
Dark (Several clicked)
Mobile
TO-BE
Light (Several clicked)
Hover mode
Dark (Several clicked)
Hover mode
Mobile
Mobile (Several clicked)
Mobile (Several clicked and clicked specipic item)
Notes
+35 / -70lines — queue management is now delegated tosonner.Summary by CodeRabbit